package com.resp;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet(urlPatterns = "/resp6",name = "resp6")
public class respond6 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 这个就是 重定向的核心技术 。

        // 通过设置不同的状态码
        resp.setStatus( HttpServletResponse.SC_FOUND );
        resp.setHeader("location" , "http://localhost:8080/resp4");
    }
}
